package dyyx.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

import com.alibaba.fastjson.JSON;

public abstract class TestDataUtil {
	
	public static void main(String[] args) throws Exception {
		
		
		List<Map<String,Object>> list = getTestEventList2();
		for(Object item:list) {
			System.out.println(item);
		}
		
	
		
		
	}
	
	
	
	
	public static List<Map<String,Object>> getEventList(String str){
		if(StringUtils.isBlank(str)){
			return null;
		}
		str = str.trim();
		
		String[]lines = StringUtils.split(str, "\n");
		Map<String,Object> event = null;
		List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
		for(String line:lines){
			if(StringUtils.isBlank(line)){
				continue;
			}
			line=line.trim();
			event = JSON.parseObject(line, Map.class);
			list.add(event);
		}	
		
		return list;		
	}
	
	public static List<Map<String,Object>> getTestEventList()throws Exception{
		String file = "data/event.txt";
		String str = CommUtil.readStringFromClassPath(file);
		return getEventList(str);
	}	
	
	public static List<Map<String,Object>> getTestEventList2()throws Exception{
		String file = "data/event2.txt";
		String str = CommUtil.readStringFromClassPath(file);
		return getEventList(str);
	}	
	
}
